package com.jerry.android.Home.data;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.jerry.android.Home.model.MainLevel0Item;
import com.jerry.android.Home.model.MainLevel1Item;
import com.jerry.android.ListView.BaseAdapterZhy.activity.BaseAdapterZhyActivity;
import com.jerry.android.ListView.brva.activity.BrvaActivity;
import com.jerry.android.TabBar.fpa.TabFPAActivity;
import com.jerry.android.TabBar.fragment.TabFragmentActivity;
import com.jerry.android.TabBar.radiobutton.TabRadioButtonActivity;
import com.jerry.android.TabBar.tabhost.TabHostActivity;
import com.jerry.android.TabBar.utilcode.TabUtilCodeActivity;
import com.jerry.android.TabBar.viewpager.TabViewPagerActivity;
import com.jerry.android.VendorDB.Realm.RealmActivity;
import com.jerry.android.model.ListInfoBean;

import java.util.ArrayList;

public class HomeData {

    private static HomeData instance;

    public static HomeData getInstance() {
        if (instance == null){
            synchronized (HomeData.class){
                instance = new HomeData();
            }
        }
        return instance;
    }

    public ArrayList<MultiItemEntity> generateData() {

        ArrayList<MultiItemEntity> homeDataList = new ArrayList<>();

        //增加List数据
        MainLevel0Item listData = generateListData();
        homeDataList.add(listData);
        //增加九宫格数据
        MainLevel0Item collectionData = generateCollectionData();
        homeDataList.add(collectionData);
        //增加TabBar数据
        MainLevel0Item tabBarData = generateTabBarData();
        homeDataList.add(tabBarData);
        //增加UI数据
        MainLevel0Item uiData = generateUIData();
        homeDataList.add(uiData);
        //增加Tool数据
        MainLevel0Item toolData = generateToolData();
        homeDataList.add(toolData);
        //增加Image数据
        MainLevel0Item imageData = generateImageData();
        homeDataList.add(imageData);
        //增加DB数据
        MainLevel0Item dbData = generateDBData();
        homeDataList.add(dbData);

        return homeDataList;
    }

    private MainLevel0Item generateListData() {
        MainLevel0Item listData = new MainLevel0Item();
        listData.title = "列表的各种效果";

        MainLevel1Item brva = new MainLevel1Item();
        brva.title = "BaseRecyclerViewAdapterHelper";
        brva.subTitle = "很好用的列表控件";
        brva.jumpClass = BrvaActivity.class;
        listData.addSubItem(brva);

        MainLevel1Item baseAdapterZhy = new MainLevel1Item();
        baseAdapterZhy.title = "ListView Base Adapter";
        baseAdapterZhy.subTitle = "zhy实现的ListView Base Adapter";
        baseAdapterZhy.jumpClass = BaseAdapterZhyActivity.class;
        listData.addSubItem(baseAdapterZhy);

        return listData;
    }

    private MainLevel0Item generateCollectionData() {
        MainLevel0Item listData = new MainLevel0Item();
        listData.title = "九宫格的各种效果";

        MainLevel1Item brva = new MainLevel1Item();
        brva.title = "BaseRecyclerViewAdapterHelper";
        brva.subTitle = "很好用的九宫格控件";
        listData.addSubItem(brva);

        return listData;
    }

    private MainLevel0Item generateTabBarData() {
        MainLevel0Item tabBarData = new MainLevel0Item();
        tabBarData.title = "TabBar的各种效果";

        MainLevel1Item tabhost = new MainLevel1Item();
        tabhost.title = "TabHost";
        tabhost.subTitle = "TabHost实现Tab";
        tabhost.jumpClass = TabHostActivity.class;
        tabBarData.addSubItem(tabhost);

        MainLevel1Item viewpager = new MainLevel1Item();
        viewpager.title = "ViewPager";
        viewpager.subTitle = "ViewPager实现Tab";
        viewpager.jumpClass = TabViewPagerActivity.class;
        tabBarData.addSubItem(viewpager);

        MainLevel1Item fragment = new MainLevel1Item();
        fragment.title = "Fragment";
        fragment.subTitle = "Fragment实现Tab";
        fragment.jumpClass = TabFragmentActivity.class;
        tabBarData.addSubItem(fragment);

        MainLevel1Item fpa = new MainLevel1Item();
        fpa.title = "ViewPager和FragmentPagerAdapter";
        fpa.subTitle = "ViewPager和FragmentPagerAdapter实现Tab";
        fpa.jumpClass = TabFPAActivity.class;
        tabBarData.addSubItem(fpa);

        MainLevel1Item radiobutton = new MainLevel1Item();
        radiobutton.title = "RadioButton";
        radiobutton.subTitle = "使用RadioButton实现实现Tab";
        radiobutton.jumpClass = TabRadioButtonActivity.class;
        tabBarData.addSubItem(radiobutton);

        MainLevel1Item utilCode = new MainLevel1Item();
        utilCode.title = "UtilCode";
        utilCode.subTitle = "使用UtilCode实现实现Tab";
        utilCode.jumpClass = TabUtilCodeActivity.class;
        tabBarData.addSubItem(utilCode);

        return tabBarData;
    }

    private MainLevel0Item generateUIData() {
        MainLevel0Item listData = new MainLevel0Item();
        listData.title = "UI框架";

        MainLevel1Item brva = new MainLevel1Item();
        brva.title = "34";
        brva.subTitle = "3434";
        listData.addSubItem(brva);

        return listData;
    }

    private MainLevel0Item generateToolData() {
        MainLevel0Item listData = new MainLevel0Item();
        listData.title = "工具框架";

        MainLevel1Item brva = new MainLevel1Item();
        brva.title = "34";
        brva.subTitle = "3434";
        listData.addSubItem(brva);

        return listData;
    }

    private MainLevel0Item generateImageData() {
        MainLevel0Item listData = new MainLevel0Item();
        listData.title = "图片框架";

        MainLevel1Item brva = new MainLevel1Item();
        brva.title = "34";
        brva.subTitle = "3434";
        listData.addSubItem(brva);

        return listData;
    }

    private MainLevel0Item generateDBData() {
        MainLevel0Item dbData = new MainLevel0Item();
        dbData.title = "数据库框架";

        MainLevel1Item realm = new MainLevel1Item();
        realm.title = "Realm";
        realm.subTitle = "Realm基本操作";
        realm.jumpClass = RealmActivity.class;
        dbData.addSubItem(realm);

        return dbData;
    }
}
